package dk.hewison;

import java.io.File;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;

/**
 * @author John Hewison
 * @author $LastChangedBy: john.hewison $:  $ $LastChangedDate: 2009-02-01 16:53:28 +0000 (Sun, 01 Feb 2009) $:
 * @version $Revision: 348 $:
 */
public class ImageFileInfoMaker {

    public ImageFileInfoMaker(String folderName) {
        File folder = new File(folderName);
        FilenameFilter filenameFilter = new FilenameFilter() {
            public boolean accept(File file, String s) {
                return s.endsWith("jpg");
            }
        };
        String[] filenames = folder.list(filenameFilter);

        File imagesTxt = new File(folderName + File.separator + "images.txt");
        if (imagesTxt.exists()) {
            imagesTxt.delete();
        }

        FileWriter fileWriter;
        try {
            fileWriter = new FileWriter(imagesTxt);
            for (String filename : filenames) {
                System.out.println(filename);
                fileWriter.append(filename + "\n");
            }
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {

        }

    }

    public static void main(String[] args) {
        new ImageFileInfoMaker("/Users/johnhewison/dev/gwt_apps/GetMyStuff/gwt-client/src/main/java/dk/hewison/public");
    }
}
